package io.renren.modules.achievements.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.achievements.entity.ResearchRewardRuleEntity;
import io.renren.modules.achievements.service.ResearchRewardRuleService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 科研奖励规则表
 *
 * @author sc
 * @email 2170147754@qq.com
 * @date 2021-12-28 10:27:57
 */
@RestController
@RequestMapping("achievements/researchrewardrule")
public class ResearchRewardRuleController {
    @Autowired
    private ResearchRewardRuleService researchRewardRuleService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("achievements:researchrewardrule:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = researchRewardRuleService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("achievements:researchrewardrule:info")
    public R info(@PathVariable("id") Long id){
		ResearchRewardRuleEntity researchRewardRule = researchRewardRuleService.getById(id);

        return R.ok().put("researchRewardRule", researchRewardRule);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("achievements:researchrewardrule:save")
    public R save(@RequestBody ResearchRewardRuleEntity researchRewardRule){
		researchRewardRuleService.save(researchRewardRule);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("achievements:researchrewardrule:update")
    public R update(@RequestBody ResearchRewardRuleEntity researchRewardRule){
		researchRewardRuleService.updateById(researchRewardRule);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("achievements:researchrewardrule:delete")
    public R delete(@RequestBody Long[] ids){
		researchRewardRuleService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
